<template>
  <div>
    <div class="returnTitle">
      <el-page-header @back="goBack" content="日常上报查详情"></el-page-header>
    </div>
    <div class="center">
      <el-form label-position="left">
        <el-form-item label="上报表名：" v-if="this.type === 1">
          自杀危机问题上报表 <el-link type="primary" :underline="false" @click="open()"><i class="el-icon-question"></i></el-link>
        </el-form-item>
        <el-form-item label="上报表名：" v-if="this.type === 3">
          严重自伤危机问题上报表 <el-link type="primary" :underline="false" @click="open()"><i class="el-icon-question"></i></el-link>
        </el-form-item>
        <el-form-item label="上报表名：" v-if="this.type === 7">
          重度抑郁问题上报表 <el-link type="primary" :underline="false" @click="open()"><i class="el-icon-question"></i></el-link>
        </el-form-item>
        <el-form-item label="上报对象：">
          {{this.$route.query.real_name}}
        </el-form-item>
      </el-form>
      <el-form ref="form" :model="form" label-position="top">
        <div v-if="this.type === 1">
          <div v-for="item in this.problem1" :key="item.type">
            <h3>{{item.type}}</h3>
            <el-form-item v-for="e in item.data" :key="e.id" :label="e.title">
              <el-radio-group v-model="e.value">
                <el-radio disabled v-for="n in e.answer" :key="e.id + n.id" :label="n.id">{{n.value}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </div>
        <div v-if="this.type === 3">
          <div v-for="item in this.problem3" :key="item.type">
            <h3>{{item.type}}</h3>
            <el-form-item v-for="e in item.data" :key="e.id" :label="e.title">
              <el-radio-group v-model="e.value">
                <el-radio disabled v-for="n in e.answer" :key="e.id + n.id" :label="n.id">{{n.value}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </div>
        <div v-if="this.type === 7">
          <div v-for="item in this.problem7" :key="item.type">
            <h3>{{item.type}}</h3>
            <el-form-item v-for="e in item.data" :key="e.id" :label="e.title">
              <el-radio-group v-model="e.value">
                <el-radio disabled v-for="n in e.answer" :key="e.id + n.id" :label="n.id">{{n.value}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </div>
        <el-form-item label="上报人：">
          <el-col :span="10">
            <el-input v-model="form.report_person" disabled></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="上报人电话：">
          <el-col :span="10">
            <el-input v-model="form.report_telephone" disabled></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="上报来源：">
          <el-col :span="10">
            <el-select v-model="form.report_source" clearable placeholder="请选择" disabled>
              <el-option v-for="item in options.source" :key="item.id" :label="item.title" :value="item.id"> </el-option>
            </el-select>
          </el-col>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import {APIEARLYWARNINGSYSTEMLIST, APICRISISGETCRISISREPORTINGDETAILS} from '@/common/api.js'
export default {
  data () {
    return {
      real_name: '',
      form: {
        report_telephone: '',
        report_source: ''
      },
      options: {},
      personnelList: [],
      type: '',
      isAddPersonnel: false,
      problem3: [
        {
          type: '一周内表现行为：',
          data: [
            {
              id: 'q1',
              title: '1、消极情绪，如焦虑、抑郁、愤怒等',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q2',
              title: '2、自我破坏行为（如，物质滥用、有严重的进食问题，从高处往下跳）',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q3',
              title: '3、拥有可以用来割伤自己的物体（如剃刀、碎玻璃、图钉等）',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q4',
              title: '4、从之前的人际关系中退缩',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q5',
              title: '5、经常呆在休息室或学校里与人隔绝的地方',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        },
        {
          type: '一周内表现身体：',
          data: [
            {
              id: 'q6',
              title: '6、非意外造成的割伤、抓伤或烧伤等',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q7',
              title: '7、经常用绷带缠着手腕或手臂',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q8',
              title: '8、不愿参加需要换衣服的活动',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q9',
              title: '9、即使在炎热的天气仍穿着长裤和长袖上衣',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q10',
              title: '10、直接观察到的自我伤害行为，如用拳头打自己/抓伤自己/撞头/咬手指、手臂/拉扯头发或抠抓皮肤等',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        },
        {
          type: '一周内表现其他：',
          data: [
            {
              id: 'q11',
              title: '11、拥有自伤史，即曾经做过伤害自己身体的事情',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q12',
              title: '12、家庭存在问题（存在酒精或毒品滥用/家暴等破环行为，环境压抑）',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q13',
              title: '13、周围同学有自伤经历',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q14',
              title: '14、患精神疾病，如抑郁症、焦虑症等',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q15',
              title: '15、无法有效面对生活中的压力事件',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q16',
              title: '16、出现与他人的分离，如父母外出务工、重要他人离世、与朋友等关系的中断等',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q17',
              title: '17、处理问题的方式消极，如回避、冲突等',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q18',
              title: '18、体验更多的负面情绪，且无法进行情绪',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q19',
              title: '19、在他人眼中的形象差',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        }
      ],
      problem1: [
        {
          type: '一周内表现潜在自杀行为：',
          data: [
            {
              id: 'q1',
              title: '1、听闻曾伤害过自己的身体，或尝试过结束自己的生命',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q2',
              title: '2、遭受过重大打击，生活中发生了很不好的事，如爸妈离婚',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q3',
              title: '3、向亲属、老师、朋友、医务人员以及其他人或在日记、作品中透露出对人生的悲观情绪，甚至表露出自杀意愿',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q4',
              title: '4、不愿意与他人讨论自杀问题',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q5',
              title: '5、和朋友，特别是有医学知识的朋友讨论与自杀有关的话题',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q6',
              title: '6、罹患精神疾病，如抑郁症、酒精药物滥用等',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q7',
              title: '7、无故看一些与“死亡”、“自杀”有关的书籍、报告',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q8',
              title: '8、无故浏览与死亡、自杀有关的网站',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q9',
              title: '9、中断与亲人和朋友的交往',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q10',
              title: '10、无故将自己珍贵的物品扔掉、烧掉或送人',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q11',
              title: '11、无故嘱咐同学帮忙照顾自己的父母',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q12',
              title: '12、无故与同学忏悔、告别并互道珍重',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        },
        {
          type: '一周内表现自杀意愿：',
          data: [
            {
              id: 'q13',
              title: '13、觉得未来没有希望，产生自杀念头',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q14',
              title: '14、有自杀计划（自杀的方法、场所、时间）',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q15',
              title: '15、自杀准备（如到考虑自杀的场所进行考察、购买药物毒药等）',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        },
        {
          type: '一周内表现对抗自杀的内部资源',
          data: [
            {
              id: 'q16',
              title: '16、精神状态差',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q17',
              title: '17、价值观念是否有助于对抗自杀',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q18',
              title: '18、对全社会，特别是周围人群抱有深刻的敌意，喜欢从阴暗面看问题',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q19',
              title: '19、缺乏决断力，犹豫不决，没有主见',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q20',
              title: '20、认识范围狭窄，采用非此即彼和以偏概全的思考方式',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q21',
              title: '21、行为具有冲动型',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q22',
              title: '22、情绪不成熟，情绪波动大',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        },
        {
          type: '一周内表现外部资源：',
          data: [
            {
              id: 'q23',
              title: '23、有可获得的情感支持和物质支持',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        }
      ],
      problem7: [
        {
          type: '一周内表现身体、生理表现：',
          data: [
            {
              id: 'q1',
              title: '1、失眠多醒、醒的过早或睡眠过多',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q2',
              title: '2、有厌食、偏食或暴饮暴食的表现，且伴随体重的剧增和剧减',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q3',
              title: '3、没有精力，难以完成大多数日常活动',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q4',
              title: '4、对很多事情反应迟缓，需要思考好几秒或者更长时间',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q5',
              title: '5、坐立不安，总是四处动，走来走去',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q6',
              title: '6、几乎不能阅读，做很小的决定都很难',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q7',
              title: '7、是否出现精神运动性兴奋或抑制的表现',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        },
        {
          type: '一周内表现心理表现：',
          data: [
            {
              id: 'q8',
              title: '8、几乎总是感到悲伤',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q9',
              title: '9、在记忆、语言表达、判断力等方面是否表现异常',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q10',
              title: '10、几乎总是谈到自己大大小小的缺点',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            },
            {
              id: 'q11',
              title: '11、对以前喜欢的活动几乎没有任何兴趣',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        },
        {
          type: '一周内表现自杀表现：',
          data: [
            {
              id: 'q12',
              title: '12、一天中多次提到死亡或者自杀/之前有自杀经历/目前有自杀计划',
              answer: [ {id: 1, value: '是'}, {id: 2, value: '否'}, {id: 3, value: '不清楚'}, {id: 4, value: '其他'} ],
              value: ''
            }
          ]
        }
      ]
    }
  },
  created () {
    this.type = Number(this.$route.query.type)
    this.selectFn()
    this.centerFn()
  },
  methods: {
    goBack () {
      this.$router.push({path: '/studentCrisis', query: {id: this.$route.query.id}})
    },
    removeTag (tag) {
      this.personnelList.splice(this.personnelList.indexOf(tag), 1)
    },
    selectPersonnelFn () {
      this.isAddPersonnel = true
    },
    noAddPersonnel (type) {
      this.personnelList = type !== [] ? type : []
      this.isAddPersonnel = false
    },
    open () {
      this.$alert('<p>（1）您需要对多种行为表现进行是、否、不确定三种判断。“是”代表上报对象表现出此种行为，“否”代表从未表现出此种行为，“不确定”代表行为表现模糊，无法判断。无论您选择“是”或“不确定”选项，请在“情况说明”一栏进行阐述。提供的信息越详细越好，例如：**时间，在**地点，**（观察对象）发生******，在场人员为：***。</p><br/><p>（2）请根据实际情况，如实填写。您的填写将会为心理老师/危机小组总干事帮助观察对象提供重要依据。</p>', '填写说明', {
        dangerouslyUseHTMLString: true
      })
    },
    selectFn () {
      APIEARLYWARNINGSYSTEMLIST().then((res) => {
        this.options = res.data
      }).catch((err) => {
        this.$message.error(err.msg)
      })
    },
    centerFn () {
      APICRISISGETCRISISREPORTINGDETAILS({
        track_record_id: this.$route.query.track_record_id
      }).then((res) => {
        this.form.report_person = res.data.report_person
        this.form.report_telephone = res.data.report_telephone
        this.form.report_source = Number(res.data.report_source)
        if (this.type === 1) {
          this.problem1.forEach(item => {
            item.data.forEach(n => {
              for (var m in res.data.content) {
                if (n.id === m) {
                  n.value = Number(res.data.content[m])
                }
              }
            })
          })
        } else if (this.type === 3) {
          this.problem3.forEach(item => {
            item.data.forEach(n => {
              for (var m in res.data.content) {
                if (n.id === m) {
                  n.value = Number(res.data.content[m])
                }
              }
            })
          })
        } else if (this.type === 7) {
          this.problem7.forEach(item => {
            item.data.forEach(n => {
              for (var m in res.data.content) {
                if (n.id === m) {
                  n.value = Number(res.data.content[m])
                }
              }
            })
          })
        }
      }).catch((err) => {
        this.$message.error(err.msg)
      })
    }
  }
}
</script>
